<!--
 * @Description: 文本垂直居中
 * @Author: charles
 * @Date: 2021-08-19 11:47:02
 * @LastEditors: charles
 * @LastEditTime: 2021-08-19 11:49:35
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>文本垂直居中</title>
  <style>
    .box {
      background-color:cornflowerblue;
      color: #fff;
      height: 100px;
      text-align: center;
    }

    .box::after {
      content: "";
      display: inline-block;
      height: 100px;
      vertical-align: middle;
    }
  </style>
</head>
<body>
  <div class="box">
    hello world
  </div>
</body>
</html>
